import 'package:flutter/material.dart';

main() {
  runApp(
    MaterialApp(
      home: Scaffold(body: ZhText('Hello Flutter', fs: 30, fc: Colors.purple)),
    ),
  );
}

//自定义“无状态的组件”
class ZhText extends StatelessWidget {
  //无状态组件没有状态，但是可以有属性
  String txt; //文本内容
  double fs; //字体大小
  Color fc; //字体颜色
  int count;    //点击次数

  ZhText(this.txt, {super.key, this.fs = 40, this.fc = Colors.green, this.count=100});

  @override
  Widget build(BuildContext context) {
    return TextButton(
      onPressed: () {
        count++;
        print('COUNT: $count');
      },
      child: Text(
        '$txt - $count',
        style: TextStyle(fontSize: fs, color: fc),
      ),
    );
  }
}
